﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZDMHelper
{
    /// <summary>
    /// 断链数据
    /// </summary>
    class ChainScission : IComparable<ChainScission>
    {
        #region Variable
        private string frontSymbol;   //断前冠号
        private double frontMileage;  //断前里程
        private string backSymbol;    //断后冠号
        private double backMileage;   //断后里程
        private double chainLength;   //断链长度，短链时为正，长链时为副
        #endregion

        #region Construction
        public ChainScission()
        {
            this.frontSymbol = "";
            this.frontMileage = 0.0;
            this.backSymbol = "";
            this.backMileage = 0.0;
            this.chainLength = 0.0;
        }

        /// <summary>
        /// 断链数据
        /// </summary>
        /// <param name="frontSymbol">断前冠号</param>
        /// <param name="frontMileage">断前里程</param>
        /// <param name="backSymbol">断后冠号</param>
        /// <param name="backMileage">断后里程</param>
        public ChainScission(string frontSymbol, double frontMileage, string backSymbol, double backMileage)
        {
            this.frontSymbol = frontSymbol;
            this.frontMileage = frontMileage;
            this.backSymbol = backSymbol;
            this.backMileage = backMileage;
            this.chainLength = frontMileage - backMileage;
        }
        #endregion

        #region Properties
        public string FrontSymbol
        {
            set
            {
                this.frontSymbol = value;
            }
            get
            {
                return this.frontSymbol;
            }
        }

        public double FrontMileage
        {
            set
            {
                this.frontMileage = value;
                this.chainLength = this.backMileage - this.frontMileage;
            }
            get
            {
                return this.frontMileage;
            }
        }

        public string BackSymbol
        {
            set
            {
                this.backSymbol = value;
            }
            get
            {
                return this.backSymbol;
            }
        }

        public double BackMileage
        {
            set
            {
                this.backMileage = value;
                this.chainLength = this.backMileage - this.frontMileage;
            }
            get
            {
                return this.backMileage;
            }
        }

        public double ChainLength
        {
            get
            {
                return this.chainLength;
            }
        }
        #endregion

        #region IComparable<ChainScission> Members

        public int CompareTo(ChainScission other)
        {
            //throw new NotImplementedException();
            return this.frontMileage.CompareTo(other.frontMileage);
        }

        #endregion
    }

    /// <summary>
    /// 断高(标尺)数据
    /// </summary>
    class BrokenHeight : IComparable<BrokenHeight>
    {
        #region Variable
        private string symbol;
        private double mileage;
        private double elvation; //标尺起点处高程
        #endregion

        #region Construction
        public BrokenHeight()
        {
            this.symbol = "";
            this.mileage = 0.0;
            this.elvation = 0.0;
        }

        /// <summary>
        /// 断高(标尺)数据
        /// </summary>
        /// <param name="symbol">冠号</param>
        /// <param name="mileage">里程</param>
        /// <param name="elvation">标尺起点处高程</param>
        public BrokenHeight(string symbol, double mileage, double elvation)
        {
            this.symbol = symbol;
            this.mileage = mileage;
            this.elvation = elvation;
        }
        #endregion

        #region Properties
        public string Symbol
        {
            set
            {
                this.symbol = value;
            }
            get
            {
                return this.symbol;
            }
        }

        public double Mileage
        {
            set
            {
                this.mileage = value;
            }
            get
            {
                return this.mileage;
            }
        }

        public double Elvation
        {
            set
            {
                this.elvation = value;
            }
            get
            {
                return this.elvation;
            }
        }
        #endregion

        #region IComparable<BrokenHeight> Members

        public int CompareTo(BrokenHeight other)
        {
            //throw new NotImplementedException();
            return this.mileage.CompareTo(other.mileage);
        }

        #endregion
    }

    /// <summary>
    /// 线路绘制方向
    /// </summary>
    public enum LineDirection
    {
        LeftToRight = 0,
        RightToLeft = 1
    }
}
